//
//  CarSourceType.m
//  CarTown
//
//  Created by xionghao on 15/9/5.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "CarSourceTypeUtils.h"
#import "CarSourceType.h"
@implementation CarSourceTypeUtils
+(void)getCarSourceType:(void (^)(bool))su{
    NSArray *array=[CarSourceType getCarSourceType];
    if (array.count>0) {
        if (su) {
            su(YES);
        }
        return;
    }else{
        NSMutableDictionary *params=[NSMutableDictionary dictionary];
        params[@"action"]=@"select";
        [PostUitls Post:catTypeurl parameters:params success:^(id response) {
            NSLog(@"%@",response);
            NSDictionary *dict=response;
            NSNumber *state=dict[@"state"];
            if ([state integerValue]==400) {
                NSArray *array=dict[@"data"];
                [CarSourceType  addCarSourceType:array];
            }
            
            if (su) {
                su(YES);
            }
            
        } failure:^(NSError *error) {
            if (su) {
                su(NO);
            }
            NSLog(@"%@",error);
        }];
        
    }

}
@end
